﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Krypton.Toolkit;
using TSNPro.Base;
using TSNPro.Communication;

namespace TSPro.MyForm
{

    public partial class FormDeviceConfig : KryptonForm
    {
        public FormDeviceConfig()
        {
            InitializeComponent();
            IniFlowLayout();
            IniDgv();
        }

        private void IniFlowLayout()
        {
            List<BaseItem> items = CommunicationManager.GetInstance().GetItems<BaseItem>();

            foreach (BaseItem item in items)
            {
                for (int i = 0; i < 6; i++)
                {
                    flCommunication.Controls.Add(item.GetConfigWidget());
                }
            }
        }

        private void IniDgv()
        {
            // 创建一个 BindingList<ConfigItem> 并填充数据
            //BindingList<ConfigItem> configItems = new BindingList<ConfigItem>
            //{
            //    new ConfigItem { Name = "设备1", Param = "参数A" },
            //    new ConfigItem { Name = "设备2", Param = "参数B" },
            //    new ConfigItem { Name = "设备3", Param = "参数C" }
            //};

            //// 绑定 BindingList 到 DataGridView
            //dgv.DataSource = configItems;

            //// 自定义列名
            //dataGridView1.Columns[0].HeaderText = "设备名";  // 第一列显示 "设备名"
            //dataGridView1.Columns[1].HeaderText = "通讯参数";  // 第二列显示 "通讯参数"
        }
    }
}
